home *** CD-ROM | disk | FTP | other *** search
/ ShareWare OnLine 2 / ShareWare OnLine Volume 2 (CMS Software)(1993).iso / cad / acadfont.zip / MKFONT.ZIP / MAKEFONT.DOC next >
Text File  |  1992-02-01  |  8KB  |  140 lines

  1. From CADENCE Magazine May, 1991
  2.  
  3. Head: Make Your Own
  4.  
  5. Sub: Create Fonts with  MAKEFONT.LSP
  6.  
  7. by Brad Halls
  8. MAKEFONT.LSP  (Listing 1) is an AutoLISP program designed to  aid  
  9. in  creating  and customizing fonts for AutoCAD. The  program  is  
  10. designed  so  that anyone can customize fonts  without  having  a  
  11. thorough  knowledge  of AutoCAD shape  files.  MAKEFONT.LSP  also  
  12. handles  the frustrating process of generating the  actual  shape  
  13. code  from  the  creator's shoulders. To  do  this,  MAKEFONT.LSP  
  14. prompts the user through the description of a character and keeps  
  15. track  of pen movements, drawing modes, and the number  of  bytes  
  16. needed  to describe the character in AutoCAD's SHP  file  format.  
  17. There  are  five  steps needed to run the program  and  create  a  
  18. custom font.
  19.  
  20. CREATING THE DRAWING 
  21. (Note: see included makefont.dxf.)
  22. Grid  size  is the first thing to consider when  creating  a  new  
  23. font.  I found that a 50 x 50 grid works well, but the base  size  
  24. is really arbitrary. In general, the more detailed the font,  the  
  25. more accuracy needed to define it and hence the larger the  grid.
  26. Once  the  size is decided, the drawing limits should be  set  to  
  27. match the grid.
  28. Next, the units and snap need to be set so that the program  will  
  29. write  integer values to the SHP file. Call up the Units  command  
  30. and set the units to "decimal" (option 2), with zero places after  
  31. the decimal point. The snap should be on and set to 1. The screen  
  32. coordinates should be on and displaying integer values. 
  33. It  is  a good idea to set up a view slightly  larger  than  your  
  34. grid, so the entire character can still be seen if you decide  to  
  35. go  outside the limits (zoom .8x should do it). Now, turn on  the  
  36. grid, save the view, and end the drawing. 
  37.  
  38. DESIGNING THE CHARACTER SET 
  39. Now  that the drawing grid is set up, you should be ready to  lay  
  40. out  individual  characters in the font.  Fortunately,  it  isn't  
  41. necessary  to  complete  the entire character  set  in  order  to  
  42. compile  the  font,  so it is possible to start  with  the  less- 
  43. complicated characters and compile them first. 
  44. Since  the program works by digitizing each character  to  create  
  45. the SHP file, no true arcs are allowed. You can, however, achieve  
  46. pretty good results by using a series of short line segments as I  
  47. have  shown  here  for the number 2 (Figure 1).  Of  course,  the  
  48. characters  don't  need  to  be drawn  out  at  all_they  can  be  
  49. digitized  from scratch. This, however, would be more  difficult.  
  50. Remember, the more vectors (points) it takes to describe a  font,  
  51. the  more  time  will be needed to display it, so  don't  get  to  
  52. detailed  unless you are prepared to wait for many of long,  slow  
  53. regens. 
  54. When  creating  a character set, it is also a good idea  to  take  
  55. advantage  of AutoCAD's subshape feature whenever  possible.  Any  
  56. character can be used as a subshape for another character, so  it  
  57. is  possible  to  save time and file  space  by  using  subshapes  
  58. creatively. One example is using the existing digits 0 through  9  
  59. as  subshapes  to create the fractional characters  1/16  through  
  60. 15/16. The keys that the fractions are assigned to are up to you.  
  61. The lowercase keys "qwerty" and "asdfg" work well if you  usually  
  62. use caps on your drawings. 
  63. Another  advantage of creating a custom font is  that  frequently  
  64. used  characters  that are are not standard ASCII,  such  as  the  
  65. "plate"  and "center line" symbols used by many AE firms, can  be  
  66. easily  added  and  assigned to any  key  available.  After  each  
  67. character  is completed to your satisfaction, make a block of  it  
  68. to be digitized later.
  69.  
  70. BEGINNING A PROTOTYPE 
  71. FONT FILE 
  72. Before  a  font can be compiled, a special shape  number  0  that  
  73. contains  information  about  the  font  name,  size,  and   text  
  74. orientation must be added. This should be the first entry in  the  
  75. SHP file, followed by the codes for a space (ASCII 32) and a line  
  76. feed  (ASCII  10). For a 50 x 50 grid, the  first  three  entries  
  77. should look something like this: (see accompanying template.shp).
  78. Copy this file and rename it  to whatever  you want to call your
  79. font, then adjust the sizes accordingly.
  80.  
  81. *0,4,fontname
  82. 50,0,2,0
  83. *32,5,space
  84. 2,8,(50,0),0
  85. *10,5,line_feed
  86. 2,8,(0,-75),0
  87.  
  88. These  lines  of code (or something similar) need to  be  written  
  89. into a file with an SHP extension and placed in the AutoCAD  root  
  90. directory  so that the character descriptions  from  MAKEFONT.LSP  
  91. can be appended to it later. 
  92.  
  93.  
  94. DEFINING A CHARACTER 
  95. Now  you  are ready to begin digitizing the characters  you  have  
  96. made and writing their descriptions to the SHP file. Call up  the  
  97. MAKEFONT.DWG  and  insert  the first character  block.  Load  the  
  98. MAKEFONT.LSP  program  and follow the  instructions  from  there.  
  99. Figure 1 shows the description process for a number 2. Start  out  
  100. by picking (0,0) for the origin and then typing "U" (for pen up).  
  101. Pick  point  number 2, and type "S" to start the  continuous  pen  
  102. down  (or  CPD)  mode.  Now  pick  continuous  points  along  the  
  103. character path through point number 3. Type "E" to exit CPD  mode  
  104. and  "U"  to raise the pen. Pick point number 4 and type  "D"  to  
  105. lower  the pen, then pick point number 5. Type "U" and  pick  the  
  106. point  (50,50). The character is now complete, so type a  "Q"  to  
  107. quit  the  description process. Note that the last point  of  one  
  108. character  is  the insertion point for the next, so  if  the  "2"  
  109. would  have  used  the  entire 50 x 50  limits,  the  last  point  
  110. digitized would have been about (60,0) instead of (50,0).
  111. The program will now ask if you want to write the description  to  
  112. a file. Respond with a "y," and MAKEFONT.LSP will prompt you  for  
  113. the  name  of  the  SHP file created in step  3.  Type  the  name  
  114. (without  the SHP extension). Next you will be prompted  for  the  
  115. ASCII  code and a short description of your character. The  ASCII  
  116. codes  for  the keyboard are listed on page 387  of  the  AutoCAD  
  117. manual. The description (not the one provided by the program  but  
  118. by  you)  should  be short and contain  no  spaces  or  uppercase  
  119. letters. Autodesk uses "uca" for an uppercase "A," but  something  
  120. like "upper_case_a" will also work and may be more readable. 
  121.  
  122. COMPILING AND TESTING THE FONT 
  123. After  the character is finished, end the MAKEFONT.DWG  and  type  
  124. "7"  at the AutoCAD main menu to compile your font. Now  go  back  
  125. into  that drawing or start a new one and create a  style  (test,  
  126. for  example)  that utilizes the new font. If all goes  well,  it  
  127. should  be possible to create a fairly large character set  in  a  
  128. short  amount  of time. Compilation errors for  shape  files  are  
  129. sometimes  difficult to find, so be patient and consult  appendix  
  130. B.7  of  the AutoCAD Reference Manual  for  further  information.  
  131. Compile  and test your font often as new letters are  created  so  
  132. that you will have a good idea of where to find any problems that  
  133. may arise. One hint is to watch for trailing blanks at the end of  
  134. lines  or a missing return at the end of the SHP file. Keep  your
  135. favorite word processor handy for debugging and have fun with it.
  136. Good Luck! @
  137.  
  138. Brad  Halls  is  a  CAD  designer  and  programmer  for  Ruby   &  
  139. Associates, P.C. in Southfield, Michigan.
  140.